<template>
	<view>
		<cu-custom bgColor="bg-gradual-blue" :isBack="true">
			<block slot="content">
				通知
			</block>
		</cu-custom>
		<a-fixed :height="40">
			<a-tabs :index="0" :row="2" type="border" :value="tabs" @click='inquire'></a-tabs>
		</a-fixed>
		<a-scroll :request="get" ref="aScroll" :parm="{pageSize:7}">
			<template #item="{row,index}">
				<uni-card-notice :title="row.title" :extra="row.extra" isShadow :note="row.date" @click="clickCard(row)">
					<text class="content-box-text">{{index+'- '+row.content}}</text>
				</uni-card-notice>
			</template>
		</a-scroll>
	</view>
</template>

<script>
	export default {
		//上拉触底
		onReachBottom() {
			this.$refs.aScroll.lower();
		},
		//下拉刷新
		onPullDownRefresh() {
			this.$refs.aScroll.get(true).then(res => {
				uni.stopPullDownRefresh();
			});
		},
		data() {
			return {
				tabs: [{
					id: "a",
					name: "班级通知"
				}, {
					id: "b",
					name: "学校通知"
				}],
				
				//默认项
				tabsParm: {
					id: "a",
					name: "班级通知"
				}
			}
		},
		methods: {
			async get(parm) {
				const data = [{
						noticeId: '第' + parm.pageNo + '页',
						title: '【全校通知】',
						extra: '未阅',
						date: new Date().toTimeString(),
						content: '关于公需科目学习的通知'
					},
					{
						noticeId: 0,
						title: '【教师通知】',
						extra: '',
						date: new Date().toTimeString(),
						content: '正安县第三中学2020-2021学年度第一学期九年级开学通知'
					},
					{
						noticeId: 0,
						title: '【家长通知】',
						extra: '',
						date: new Date().toTimeString(),
						content: '关于八、九年级家长本学期未收到学生进出校的通知'
					},
					{
						noticeId: 0,
						title: '【教师通知】',
						extra: '未阅',
						date: new Date().toTimeString(),
						content: '关于公需科目学习的通知'
					},
					{
						noticeId: 0,
						title: '【全校通知】',
						extra: '未阅',
						date: new Date().toTimeString(),
						content: '正安县第三中学2020-2021学年度第一学期九年级开学通知'
					},
					{
						noticeId: 0,
						title: '【全校通知】',
						extra: '未阅',
						date: new Date().toTimeString(),
						content: '关于公需科目学习的通知'
					},
					{
						noticeId: 0,
						title: '【教师通知】',
						extra: '',
						date: new Date().toTimeString(),
						content: '正安县第三中学2020-2021学年度第一学期九年级开学通知'
					},
				];
				console.log('请求：' + JSON.stringify({
					...parm,
					...this.tabsParm,
				}))
				return new Promise(r => {
					setTimeout(e => {
						r({
							total: 70,
							data
						})
					}, 1000);
				});
			},
			inquire(e) {
				this.tabsParm = e;
				this.$refs.aScroll.get(true);
			},
			clickCard(e) {
				uni.navigateTo({
					url: './notice_details?id='+e.id
				});
			}
		}
	}
</script>

<style lang="scss">
	.content-box-text {
		font-size: 15px;
		font-weight: 500;
		line-height: 22px;
	}
</style>
